<template>
  <Header :check="2"
          @getUserInfo="getUserInfo" />
  <div class="clear_nav"></div>
  <div id="order">
    <div class="list">
      <template v-if="investAmount > 0">
        <div class="cell">
          <div>
            <p>{{ $t("hl_joinAmount") }} {{ investAmount }} USDT</p>
            <h5>{{ $t("hl_success") }}</h5>
          </div>
          <p>
            {{ $t("hl_incoumeDouble") }}: {{ parseFloat(outAmount / investAmount).toFixed(0)
            }}{{ $t("hl_doubt") }}
          </p>
        </div>
      </template>
      <template v-else>
        <div class="no_data">
          <img src="../assets/img/mine/nodata.png" />
          <div>{{ $t("hl_noData") }}</div>
        </div>
      </template>
    </div>
  </div>
</template>

<script setup>
import { } from "../request/api";
import { ref, reactive, watch } from "vue";
import {
  showFailToast,
  showSuccessToast,
  showLoadingToast,
  closeToast,
} from "vant";
import { getFloat, getEstimateGas } from "../utils/common";
import { useRouter } from "vue-router";
import i18n from "@/lang";
import api from "../dapp/api";

const router = useRouter();

let address = ref("");
let orderList = ref([]);

let outAmount = ref(0);
let getAmount = ref(0);
let investAmount = ref(0);

// 那得的数据
function getUserInfo (obj) {
  address.value = obj.address;

  outAmount.value = obj.web3.utils.fromWei(obj.userData.outAmount, "ether");
  getAmount.value = obj.web3.utils.fromWei(obj.userData.getAmount, "ether");

  investAmount.value = obj.web3.utils.fromWei(
    obj.userData.investAmount,
    "ether"
  );
}

function formatDateTime (value) {
  // 时间戳转换日期格式方法
  if (value == null)
  {
    return "";
  } else
  {
    const date = new Date(value);
    const y = date.getFullYear(); // 年
    let MM = date.getMonth() + 1; // 月
    MM = MM < 10 ? "0" + MM : MM;
    let d = date.getDate(); // 日
    d = d < 10 ? "0" + d : d;
    let h = date.getHours(); // 时
    h = h < 10 ? "0" + h : h;
    let m = date.getMinutes(); // 分
    m = m < 10 ? "0" + m : m;
    let s = date.getSeconds(); // 秒
    s = s < 10 ? "0" + s : s;
    return y + "-" + MM + "-" + d + " " + h + ":" + m + ":" + s;
  }
}
</script>

<style scoped lang="less">
#order {
  padding: 10px 3% 0;

  .list {
    .cell {
      width: 100%;
      padding: 3%;
      background: #f2f2f2;
      border-radius: 12px;
      box-shadow: 1px 1px 2px 1px #999;
      margin-bottom: 12px;
      div {
        display: flex;
        align-content: center;
        justify-content: space-between;
        // margin-bottom: 4px;
      }

      p {
        color: #696565;
        margin-bottom: 6px;
      }

      h5 {
        color: #1296db;
      }
    }
  }
}
</style>
